import request from '@/utils/request';

// 查询创客热点列表
export function getHotActivities() {
  return request({
    url: '/activities/activity/getHotActivities',
    method: 'get'
  });
}

// 查询创客动态列表
export function listActivity(query) {
  return request({
    url: '/activities/activity/list',
    method: 'get',
    params: query
  });
}

// 查询创客动态详细
export function getActivity(activityId) {
  return request({
    url: '/activities/activity/' + activityId,
    method: 'get'
  });
}

// 新增创客动态
export function addActivity(data) {
  return request({
    url: '/activities/activity',
    method: 'post',
    data: data
  });
}

// 修改创客动态
export function updateActivity(data) {
  return request({
    url: '/activities/activity',
    method: 'put',
    data: data
  });
}

// 删除创客动态
export function delActivity(activityId) {
  return request({
    url: '/activities/activity/' + activityId,
    method: 'delete'
  });
}

// 多图片上传
export function uploadMultipleImages(files) {
  console.log("进入接口uploadMultipleImages");
  
  const formData = new FormData();
  Array.from(files).forEach((file) => {
    formData.append('files', file);
  });

  return request({
    url: '/upload/images', // 与后端定义的接口路径一致
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}